package com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.persenter;

import android.content.Context;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;


import com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter.NoScrollViewPagerAdapter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.custom_view.NoScrollViewPager;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_view.DevicesManagerFragment;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_view.DownloListFragment;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_view.MeetingFragment;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_view.PersonalCenterFragment;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_view.ShareListFragment;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.contract.IMainContract;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/8/8.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class Mainpersenter implements IMainContract.IMainpersenter {
    private IMainContract.IMainView mIMainView;


    public Mainpersenter(IMainContract.IMainView mIMainView) {
        this.mIMainView = mIMainView;
    }
    @Override
    public List<Fragment> init(Context mContext) {
        List<Fragment> list = new ArrayList<>();
        list.add(new DevicesManagerFragment());
        list.add(new MeetingFragment());
        list.add(new DownloListFragment());
        list.add(new ShareListFragment());
        list.add(new PersonalCenterFragment());
        return list;
    }

    @Override
    public void setListener(final NoScrollViewPager mNoScrollViewPager, TabLayout mTabLayout) {
        mNoScrollViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
        mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                //tab被选的时候回调
                mNoScrollViewPager.setCurrentItem(tab.getPosition(),false);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                //tab未被选择的时候回调
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
                //tab重新选择的时候回调
            }
        });
    }

    @Override
    public void addTabs(NoScrollViewPagerAdapter mNoScrollViewPagerAdapter, TabLayout mTabLayout) {
        //设置自定义视图
        for (int i = 0; i < mTabLayout.getTabCount(); i++) {
            TabLayout.Tab tab = mTabLayout.getTabAt(i);
            tab.setCustomView(mNoScrollViewPagerAdapter.getTabView(i,mTabLayout));
        }
    }

}
